package cfca.payment.socket;

import org.w3c.dom.Document;
import payment.tools.security.SignatureFactory;
//import payment.tools.security.Signer;
import payment.tools.util.Base64;
import payment.tools.util.StringUtil;
import payment.tools.util.XmlUtil;

public class TxBaseRequest {

	private String txCode;
	private String requestPlainText;
	private String requestMessage;
	private String requestSignature;
	public String getRequestPlainText() {
		return requestPlainText;
	}

	public String getRequestMessage() {
		return requestMessage;
	}

	public String getRequestSignature() {
		return requestSignature;
	}
	
	public void postProcess(Document paramDocument) throws Exception {
		this.requestPlainText = XmlUtil.createPrettyFormat(paramDocument)
				.trim();

		byte[] arrayOfByte1 = this.requestPlainText.getBytes("UTF-8");

		this.requestMessage = new String(Base64.encode(arrayOfByte1));

		byte[] arrayOfByte2 = SignatureFactory.getSigner().sign(arrayOfByte1);

		this.requestSignature = StringUtil.bytes2hex(arrayOfByte2);
	}

}
